<?php if (!defined('THINK_PATH')) exit();?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>ECSHOP 管理中心 - 商品分类 </title>
<meta name="robots" content="noindex, nofollow">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link href="/smfs/Public/admin/css/general.css" rel="stylesheet" type="text/css" />
<link href="/smfs/Public/admin/css/main.css" rel="stylesheet" type="text/css" />

<script type="text/javascript" src="/smfs/Public/admin/js/x-layui.js"></script>
<link href="/smfs/Public/css/layui.css" rel="stylesheet" type="text/css" media="all"/>
<script type="text/javascript" src="/smfs/Public/layui.js"></script>

</head>
<body>

<h1>
<span class="action-span"><a href="<?php echo U('admin/cat/cateadd');?>">添加分类</a></span>
<span class="action-span1"><a href="#">商品分类</a> </span>
<div style="clear:both"></div>
</h1>
<form method="post" action="" name="listForm">
<div class="list-div" id="listDiv">

<table width="100%" cellspacing="1" cellpadding="2" id="list-table">
  <tr>
    <th align="left">分类名称</th>
    <th>商品数量</th>
    <th>数量单位</th>
    <th>分类简介</th>
    <th>是否显示</th>
    <th>操作</th>
  </tr>
<?php foreach ($cats as $v) { ?>
    <tr align="center" style="border: 1px solid #fbf1f1;">
    <td align="left" width="10%" style="border-right: 1px solid #f1f1f1;">
        <img src="/smfs/Public/admin/images/menu_minus.gif" style="margin-left:<?php echo ($v["lev"]); ?>em" />
        <span><a href="#" ><?php echo ($v["cat_name"]); ?></a></span>
    </td>
    <td width="5%" style="border-right: 1px solid #f1f1f1;">0</td>
    <td width="5%" style="border-right: 1px solid #f1f1f1;"><span>件</span></td>
    <td width="20%" style="border-right: 1px solid #f1f1f1;"><?php echo (mb_substr(strip_tags(htmlspecialchars_decode($v["intro"])),0,15,'utf-8')); ?>...</td>
    <td width="10%" style="border-right: 1px solid #f1f1f1;"><img src="/smfs/Public/admin/images/yes.gif" /></td><!-- /smfs/Public/admin/images/no.gif -->
    <td width="20%" style="border-right: 1px solid #f1f1f1;">
      <a title="编辑" href="javascript:;" onclick="admin_edit('编辑','<?php echo U('admin/cat/catedit',array('cat_id'=>$v['cat_id']));?>','4','500','500')">编辑</a> 
      <span style="padding: 0 10px;">|</span>
      <a title="删除" href="javascript:;" onclick="admin_del(this,'<?php echo ($v['cat_id']); ?>')" >删除</a>
    </td>
  </tr>
<?php } ?>
  </table>
</div>
</form>

<div id="footer">
共执行 1 个查询，用时 0.015927 秒，Gzip 已禁用，内存占用 1.999 MB<br />

版权所有 &copy; 2005-2010 上海商派网络科技有限公司，并保留所有权利
。</div>

<script>
    layui.use(['laydate','element','laypage','layer'], function(){
        $ = layui.jquery;//jquery
      laydate = layui.laydate;//日期插件
      lement = layui.element();//面包导航
      laypage = layui.laypage;//分页
      layer = layui.layer;//弹出层


    });


    //编辑
    function admin_edit (title,url,id,w,h) {
        x_admin_show(title,url,w,h); 
    }

    /*删除*/
    function admin_del(obj,id){
        layer.confirm('确认要删除吗？',function(index){
          //发异步删除数据
          cat_id = id;
          $.ajax({
              url: "<?php echo U('admin/cat/catedel');?>",//请求地址
              type: "post",//请求方式
              dataType: "json",//返回数据类型
              data: {cat_id:cat_id},//发送的参数
              })
              .done(function(response) {
                    if(response.error==1){
                      layer.msg(response.info ,{icon:6});
                      $(obj).parents("tr").remove();
                    }else{
                      layer.msg(response.info ,{icon:5});
                    }
                })
              .fail(function() {
                  alert("ajxs交互失败");
              })  
          return false;
        });
    }
</script>
</body>
</html>